package com.im.server.handle.impl;

import com.im.server.handle.MessageService;
import com.im.server.protocol.MessageProto;
import org.springframework.stereotype.Component;

import static com.im.common.Constants.CommandType.MESSAGE;

/**
 * @author gongym
 * @date 2019/1/20 22:26
 */
@Component("UserMessageServiceImpl")
public class UserMessageServiceImpl implements MessageService {

  @Override
  public MessageProto.MessageProtocol handleMessage(MessageProto.MessageProtocol messageProtocol) {
    return MessageProto.MessageProtocol.newBuilder()
        .setFrom(messageProtocol.getFrom())
        .setTo(messageProtocol.getTo())
        .setCreateTime(System.currentTimeMillis())
        .setContent(messageProtocol.getContent())
        .setType(MESSAGE)
        .build();
  }
}
